
// 接口
public interface Inface {

    //定义接口 （修饰符 public abstract 可省略）
    public abstract double getTax();
}


//抽象类
abstract class Inc implements Inface{
    //定义属性（字段）
    protected double income;
}


//执行入口
class Hahs{
    
    public static void main(String[] args){
        //System.out.print("hshs");
        Inface[] incomes = {
            new Gz(12000),
            new Syl(15000),
        };


        //调用 getTotalTax
        getTotalTax(incomes);
    }


    public static void getTotalTax(Inface... incomes){
        double total = 0;

        for(Inface income : incomes ){
            total += income.getTax();
        }
        System.out.println(total);


        //调用静态方法
        new Sta();
        new Sta();
        new Sta();
        int count = Sta.getCount();
        System.out.printf("实例被调用了 %d 次", count);

    }
}


//实现接口-1
class Gz extends Inc{
    
    public Gz(double in){
        this.income = in;
    }
    

    @Override
    public double getTax(){
        return this.income * 0.1;
    }
}



//实现接口-2
class Syl extends Inc{
    
    public Syl(double in){
        this.income = in;
    }

    @Override
    public double getTax(){
        return this.income * 0.2;
    }
}



// 静态字段和静态方法
class Sta {

    //静态字段
    public static int count = 0;

    //构造方法
    public Sta (){
        Sta.count +=1;
    }

    public static int getCount(){
        return Sta.count;
    }
}

